home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 081 / badusr12.arc / BU12_SRC.ARC / BADUSR12.BAS next >
Encoding:
BASIC Source File  |  1987-09-02  |  10.0 KB  |  334 lines

  1. option base 1
  2. defint a-z
  3. '************************************************
  4. getparm:                'get command line
  5. '************************************************
  6.  
  7.   ansi$=chr$(27)+"[32;40;1m"                          'color code for .gbs file.
  8.   cm$=command$
  9.   beep$="NO"
  10.   path$=""
  11.   pass$=""
  12.   while right$(cm$,1)=" "
  13.     t$=cm$
  14.     t=len(cm$)-1
  15.     cm$=left$(t$,t)
  16.   wend
  17.   cm$=cm$+" "
  18.    if cm$=" " goto noinfo
  19.    dim cc$(30)
  20.    ccount=1
  21.    ref=1
  22.  
  23.    while not 0=instr(ref,cm$,"-C")                       '-C display
  24.      cc=1
  25.      cm=instr(ref,cm$,"-C")
  26.      z=instr(cm,cm$," ")
  27.      tmpc$=mid$(cm$,cm+2,z)
  28.      z=instr(tmpc$," ")
  29.      if not z=0 then cc$(ccount)=mid$(tmpc$,1,z-1) else cc$(ccount)=tmpc$
  30.      ccount=ccount+1
  31.      ref=cm+z
  32.    wend
  33.    cm=instr(cm$,"-B")                                     '-B  Beep
  34.      if not cm=0 then
  35.     beep$="YES"
  36.       end if
  37.                                                            '-L lastuser display
  38.     CM=INSTR(CM$,"-L")
  39.      if not cm=0 then
  40.     l=1
  41.      end if
  42.  
  43.    CM=INSTR(CM$,"-P")                                         '-P Path
  44.      if not cm=0 then
  45.        z=instr(cm+2,cm$,chr$(32))
  46.      pathtmp$=mid$(cm$,cm+2,z-3)
  47.      Z=INSTR(PATHTMP$," ")
  48.      if not z=0 then path$=mid$(pathtmp$,1,z-1) else path$=pathtmp$
  49.      IF NOT RIGHT$(PATH$,1)="\" THEN PATH$=PATH$+"\"
  50.       end if
  51.  
  52.     CM=INSTR(CM$,"-O")                                        '-O User ok - Pass
  53.       if not cm=0 then
  54.     z=instr(cm+2,cm$,chr$(32))
  55.       passtmp$=mid$(cm$,cm+2,z-3)
  56.       Z=INSTR(PASSTMP$," ")
  57.       if not z=0 then o$=mid$(passtmp$,1,z-1) else o$=passtmp$
  58.        end if
  59.  
  60.        cmtmp$=cm$+"-"
  61.      cm=instr(cmtmp$,"-S")                                      '-S Sysops name
  62.        if not cm=0 then
  63.          z=instr(cm+2,cmtmp$," -")
  64.          z1=instr(cm+2,cmtmp$,"  ")
  65.            if not z=0 then
  66.              sysop$=mid$(cmtmp$,cm+2,z)
  67.            end if
  68.          z=instr(sysop$,"-")
  69.          if not z=0 then sysop$=left$(sysop$,z-1)
  70.          while right$(sysop$,1)=" "
  71.            sysop$=left$(sysop$,len(sysop$)-1)
  72.          wend
  73.        end if
  74.  
  75.      cm=instr(cm$,"-D")                                     '-D DTR drop
  76.        if not cm=0 then
  77.          z=instr(cm+2,cm$,chr$(32))
  78.          dtr$=mid$(cm$,cm+2,z-3)
  79.          dtr$=left$(dtr$,1)
  80.          select case dtr$
  81.            case "1","2"
  82.            case else
  83.            print"ERROR: Can only specify com port 1 or 2 for DTR drop."
  84.            dtr$=""
  85.          end select
  86.        end if
  87.  
  88.  
  89. '*****************************************************************************
  90.  find.names:                  'Find & organize current & previous users names.
  91. '*****************************************************************************
  92.   on error goto handler
  93.     call exist("\opus\lastuser.bbs"+chr$(0),filexists)
  94.     if filexists then
  95.       open "r",1,"\opus\lastuser.bbs",72
  96.         field 1,36 as fulln$,_
  97.                 36 as s$
  98.           get 1
  99.           n$=fulln$
  100.           current.state$=s$
  101.           close 1
  102.         while right$(n$,1)=chr$(0)
  103.           n$=left$(n$,len(n$)-1)
  104.         wend
  105.         lcase.fulln$=n$
  106.         call upcase(n$)
  107.         z=instr(n$," ")
  108.         if not z=0 then
  109.           fstn$=left$(n$,z-1)
  110.           lstn$=right$(n$,len(n$)-z)
  111.         elseif z=0 then
  112.           fstn$=n$
  113.         end if
  114.         while right$(current.state$,1)=chr$(0)
  115.           current.state$=left$(current.state$,len(current.state$)-1)
  116.         wend
  117.       else
  118.       print"Can't find "+chr$(34)+"\opus\lastuser.bbs"+chr$(34)+"."
  119.       print"Please see the documentation."
  120.       system
  121.       end if
  122.  
  123. '*****************************************************************************
  124. search:                              'Search "BADUSER.DAT" for matching names.
  125. '*****************************************************************************
  126.   color 2,0:print"Checking user name...      ";:color 15,0:print lcase.fulln$
  127.   open "i",1,path$+"baduser.dat"
  128.  
  129.   while not eof(1)
  130.     input #1,bad$
  131.     call upcase(bad$)
  132.     if fstn$=bad$ or lstn$=bad$ or n$=bad$ goto baduser
  133.   wend
  134.  
  135.  
  136. '*****************************************************************************
  137.  gooduser:                               'Ok, I *guess* we'll let you through.
  138. '*****************************************************************************
  139.   close 1
  140.   if l=1 then
  141.     open "r",1,path$+"lastuser.dat",72
  142.       field 1,36 as tmp$,_
  143.               36 as s$
  144.         get 1,1
  145.       while right$(tmp$,1)=chr$(0) or right$(tmp$,1)=" "
  146.         tmp$=left$(tmp$,len(tmp$)-1)
  147.       wend
  148.       lastuser$=tmp$
  149.       while right$(s$,1)=chr$(0) or right$(s$,1)=" "
  150.         s$=left$(s$,len(s$)-1)
  151.       wend
  152.       lastuser.state$=s$
  153.       gosub clean.state
  154.       close 1
  155.     if not n$=sysop$ then
  156.       open "r",1,path$+"lastuser.dat",72
  157.         field 1,36 as tmp$,_
  158.                 36 as s$
  159.       lset tmp$=lcase.fulln$
  160.       lset s$=current.state$
  161.       put 1,1
  162.       close 1
  163.     end if
  164.   end if
  165.   open "o",1,path$+"baduser.bbs"
  166.   open "o",2,path$+"baduser.gbs"
  167.   print #1,chr$(2)
  168.   print #2,chr$(2)
  169.  
  170.     if cc=1 then
  171.       for x=1 to ccount
  172.     print #1,cc$(x)
  173.     print #2,ansi$+cc$(x)
  174.       next x
  175.     end if
  176.  
  177.     if l=1 then
  178.       gosub greeting
  179.       print #1,greet$+chr$(6)+chr$(6)+"."
  180.       print #2,ansi$+greet$+chr$(6)+chr$(6)+"."
  181.     if not lastuser.state$="" then
  182.       if not left$(lastuser$,1)=chr$(26) then
  183.         print #1,lastuser$+" from "+lastuser.state$+" was the previous caller."
  184.         print #2,ansi$+lastuser$+" from "+lastuser.state$+" was the previous caller."
  185.       end if
  186.     end if
  187.     end if
  188.     print #1,chr$(15)+"F"+o$
  189.     print #2,chr$(15)+"F"+o$
  190.  
  191.     close
  192.     system
  193.  
  194. '*****************************************************************************
  195.  baduser:                                              'Go ahead, make my day!
  196. '*****************************************************************************
  197.     close 1
  198.     if beep$="YES" then
  199.       for z=1 to 6
  200.     for i=440 to 1000 STEP 3.0     
  201.       sound i,i/20000
  202.     next i
  203.     for i=1000 to 440 step 3.0
  204.       sound i, i/20000
  205.     next i
  206.     if z=3 then
  207.       color 28,0
  208.       print"Invalid name. Ejecting...  ";:color 15,0:print lcase.fulln$
  209.     end if
  210.       next z
  211.     else
  212.       color 28,0
  213.       print"Invalid name. Ejecting...  ";:color 15,0:print lcase.fulln$
  214.     end if
  215.       if not dtr$="" then                    'This is easier than generating
  216.         if dtr$="1" then dtrval=1        'an interrupt with the fossil.       
  217.         if dtr$="2" then dtrval=2
  218.         call dtr(dtrval,0)
  219.         call delay(1)
  220.         call dtr(dtrval,1)
  221.       end if
  222.   open "o",1,path$+"baduser.bbs"
  223.   open "o",2,path$+"baduser.gbs"
  224.     print #1,chr$(2)
  225.     print #2,chr$(2)
  226.     for x=1 to 5:print #1,chr$(7);:next x
  227.     for x=1 to 5:print #2,chr$(7);:next x
  228.     print #1,"Access Denied!";
  229.     print #1,
  230.     print #1,chr$(6)+chr$(14)
  231.     print #2,chr$(27)+"[31;40;5mAccess Denied!";
  232.     print #2,
  233.     print #2,chr$(6)+chr$(14)
  234.   close
  235.   system
  236.  
  237. '-----------------------------------------------------------------------------
  238. Clean.state:                            'Clean-up that awful formatting <grin>
  239. '-----------------------------------------------------------------------------
  240.   if lastuser.state$="" then return
  241.   tmp.state$=lastuser.state$
  242.     z=instr(tmp.state$,",")
  243.       if not mid$(tmp.state$,z+1,1)=" " then
  244.         tmp.state$=left$(tmp.state$,z)+" "+mid$(tmp.state$,z+1,len(tmp.state$)-z)
  245.         lastuser.state$=tmp.state$
  246.       end if
  247.     z=instr(tmp.state$,", ")
  248.       if not z=0 then
  249.         if len(mid$(tmp.state$,z+2,len(tmp.state$)-(z-4))) => 3 then
  250.           z1$=left$(tmp.state$,1)
  251.           z2$=mid$(tmp.state$,z+2,1)
  252.           call upcase(z1$)
  253.           call upcase(z2$)
  254.           tmp.state$=z1$+mid$(tmp.state$,2,z)+z2$+mid$(tmp.state$,z+3,len(tmp.state$)-(z-4))
  255.           lastuser.state$=tmp.state$
  256.         else
  257.           z1$=left$(tmp.state$,1)
  258.           z2$=mid$(tmp.state$,z+2,2)
  259.           call upcase(z1$)
  260.           call upcase(z2$)
  261.           tmp.state$=z1$+mid$(tmp.state$,2,z)+z2$
  262.           lastuser.state$=tmp.state$
  263.         end if
  264.       elseif z=0 then
  265.         while left$(tmp.state$,1)=chr$(0) or left$(tmp.state$,1)=" "
  266.           tmp.state$=right$(tmp.state$,len(tmp.state$)-1)
  267.         wend
  268.         x=1
  269.         z1$=left$(tmp.state$,1)
  270.         call upcase(z1$)
  271.         tmp.state$=z1$+mid$(tmp.state$,2,len(tmp.state$)-1)
  272.         do
  273.           z=instr(x,tmp.state$," ")
  274.           if not z=0 then
  275.             z1$=mid$(tmp.state$,z+1,1)
  276.             call upcase(z1$)
  277.             tmp.state$=left$(tmp.state$,z)+z1$+mid$(tmp.state$,z+2,len(tmp.state$)-(z-2))
  278.             x=z+1
  279.            end if
  280.            lastuser.state$=tmp.state$
  281.         loop until z=0
  282.       end if
  283. return
  284.  
  285. '-----------------------------------------------------------------------------
  286. Greeting:                                      'Why thankyou Gilligan!                 
  287. '-----------------------------------------------------------------------------
  288.  
  289.      IF TIME$ <= "11:59:59" THEN
  290.        GREET$="Good morning "
  291.        return
  292.      end if
  293.      IF TIME$ <= "17:59:59" THEN
  294.        GREET$="Good afternoon "
  295.        return
  296.      end if
  297.      GREET$="Good evening "
  298.   return
  299.  
  300.  
  301. '******************************************************************************
  302.  handler:                                                   'The error handler.
  303. '******************************************************************************
  304.      PRINT"Can't find Path "+PATH$
  305.   close
  306.   system
  307.  
  308. '******************************************************************************
  309.  noinfo:                       'No parameters from the command line comes here.
  310. '******************************************************************************
  311.   PRINT"      BADUSER  v1.20
  312.   PRINT"      Copyright(c) 1987 by Greg Dawson
  313.   PRINT"      ShutterBUG  (106/111)                        (713)880-4329
  314.   PRINT"      ----------------------------------------------------------
  315.   PRINT"      Usage...
  316.   PRINT"      ----------------------------------------------------------
  317.   PRINT"        BADUSER -b -o -p -c -l -d -s
  318.   print
  319.   PRINT"           -b  <== Turns on the alarm.
  320.   PRINT"           -o  <== Path and file to display if the user is Ok.
  321.   PRINT"           -p  <== Path to the BADUSER support files.
  322.   PRINT"           -c  <== Control character(s) to display if user Ok.
  323.   PRINT"           -l  <== Enable last user display.
  324.   print"           -d1 <== Lower/Raise DTR to drop user (Port 1 or 2).
  325.   print"           -s  <== Sysops name.
  326.   print
  327.   PRINT"      A typical command line might go as follows...
  328.   print
  329.   PRINT"      BADUSER  -d1 -b -l -sGreg Dawson -oC:\opus\misc\welcome2 -pC:\opus\ -c"+CHR$(1)
  330. system
  331.  
  332.  
  333.  
  334.